package com.sc.nft.mapper;


import cn.hutool.core.date.DateTime;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.sc.nft.entity.UserRelevance;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.util.List;

@Mapper
public interface    UserRelevanceMapper extends BaseMapper<UserRelevance> {


    /**
     * 批量入库
     *
     * @param list
     * @return
     */
    Boolean saveBatch(@Param("list") List<UserRelevance> list);

    /**
     * 根据用户id和等级屏障获取数据
     * @param userId
     * @return
     */
    List<Long> userRelevanceByUserId(@Param("userId") Long userId );




    /**
     * 获取最近的服务中心
     * @param userId
     * @return
     */
    List<Long> getNearCityServer(@Param("userId") Long userId);

    /**
     * 获取最近的工作室
     * @param userId
     * @return
     */
    List<Long> getNearWorkRoom(@Param("userId") Long userId);

    Integer getByUserIdAndLvAndNotInRelevanceIdCount(@Param("userId") Long userId,@Param("start") String start   );

    List<Long> excludeSubordinateCommunity(@Param("userId") Long userId, @Param("info") List<Long> info, @Param("cityList") List<Long>excludesTheCityServiceCenterOfTheCurrentUser);
    List<Long> excludeCityServiceCenters(@Param("userId") Long userId, @Param("info") List<Long> info);

    List<Long> excludeSubordinateCommunityWithLv(@Param("userId") Long userId, @Param("info") List<Long> info, @Param("cityList") List<Long>excludesTheCityServiceCenterOfTheCurrentUser,@Param("lv")Integer lv);

    List<Long> excludeCityServiceCentersWithLv(@Param("userId") Long userId, @Param("info") List<Long> info,@Param("lv")Integer lv);


    /**
     * 排除用户名下的城市服务中心
     * @param userId
     * @return
     */
    List<Long> excludesTheCityServiceCenterOfTheCurrentUser(@Param("userId") Long userId);
    /**
     * 获取直推社区网点
     * @param userId
     * @return
     */
    Integer directThrustCommunityNetworkCount(@Param("userId") Long userId);
    /**
     * 获取直推城市服务中心
     * @param userId
     * @return
     */
    Integer directThrustUrbanServiceCenterCount(@Param("userId") Long userId);
    /**
     * 下级必须是这个用户网体内的,并且必须要是没被截断的
     * @param userId
     * @param relevanceId
     * @return
     */
    Integer verifyThatTheUserIsInTheirOwnNetwork(@Param("userId") Long userId, @Param("relevanceId") Long relevanceId);

    /**
     * 获取最近直接服务中心
     * @param userId
     * @return
     */
    Long getNearDirectCityServer(@Param("userId") Long userId);

    /**
     * 获取最近直接社区网点
     * @param userId
     * @return
     */
    Long getNearDirectWorkRoom(@Param("userId") Long userId);

    List<Long> userRelevanceByUserIdList(@Param("userIdList") List<Long> userIdList);

    List<UserRelevance> ListByUserIdAndRelevanceIdAndLvAndWeekCollection(@Param("userId") Long userId, @Param("participationSmeltUserIds") List<Long> participationSmeltUserIds, @Param("dayStart") DateTime beginOfWeek,@Param("dayEnd") DateTime endOfWeek, @Param("lv") int lv, @Param("collectionId") Long collectionId, @Param("code") int code);

    List<UserRelevance> ListByUserIdAndRelevanceIdAndLvAndDayCollection(@Param("userId") Long userId, @Param("participationSmeltUserIds") List<Long> participationSmeltUserIds, @Param("day") int day, @Param("lv") int lv, @Param("collectionId") Long collectionId, @Param("code") int code);
}
